<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:dxdb="clr-namespace:UColor.WPF"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:helpers="clr-namespace:UColor.WPF.Helpers"
    xmlns:ddhelpers="clr-namespace:UColor.Core.Helpers;assembly=UColor.Core"
    xmlns:dxl="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <ddhelpers:GlobalResource x:Key="ScrollBarResource" Assembly="UColor.Core" XamlPath="Window/ScrollBar.xaml" Key="ScrollBar" />

    <ddhelpers:SelectConverter x:Key="TileMouseOverOpacityConverter">
        <ddhelpers:SelectState Key="False" Value="{ddhelpers:DoubleValue S=0}" />
        <ddhelpers:SelectState Key="True" Value="{ddhelpers:DoubleValue S=1}" />
    </ddhelpers:SelectConverter>
    <Style x:Key="TileStyle" TargetType="dxl:Tile">
        <Setter Property="ddhelpers:IsMouseOverHelper.EnableIsMouseOver" Value="Enable" />
        <Setter Property="BorderBrush" Value="#1AFFFFFF" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="FontFamily" Value="Segoe UI, Tahoma" />
        <Setter Property="FontSize" Value="12" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="HorizontalHeaderAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalHeaderAlignment" Value="Bottom" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Padding" Value="16,5" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="dxl:Tile">
                    <Grid Name="root" RenderTransformOrigin="0.5,0.5" dx:FrameworkElementHelper.IsClipped="True">
                        <Grid.RenderTransform>
                            <ScaleTransform />
                        </Grid.RenderTransform>
                        <Grid.Resources>
                            <dx:MultiplyConverter x:Key="MultiplyConverter" />
                            <Storyboard x:Name="ContentChangeStoryboard" x:Key="ContentChangeStoryboard" FillBehavior="Stop">
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="previousContent" Storyboard.TargetProperty="Visibility"
                                                               Duration="0:0:0.15" FillBehavior="Stop">
                                    <ObjectAnimationUsingKeyFrames.KeyFrames>
                                        <DiscreteObjectKeyFrame KeyTime="0">
                                            <DiscreteObjectKeyFrame.Value>
                                                <Visibility>Visible</Visibility>
                                            </DiscreteObjectKeyFrame.Value>
                                        </DiscreteObjectKeyFrame>
                                    </ObjectAnimationUsingKeyFrames.KeyFrames>
                                </ObjectAnimationUsingKeyFrames>
                                <DoubleAnimation Storyboard.TargetName="previousContent" Storyboard.TargetProperty="(RenderTransform).Y"
                                                 To="{Binding ElementName=root, Path=ActualHeight, Converter={StaticResource MultiplyConverter}, ConverterParameter=-1}"
                                                 Duration="0:0:0.15" />
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="content" Storyboard.TargetProperty="(RenderTransform).Y"
                                                               Duration="0:0:1">
                                    <DiscreteDoubleKeyFrame KeyTime="0" Value="{Binding ElementName=root, Path=ActualHeight}" />
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0.15" Value="{Binding ElementName=root, Path=ActualHeight}" />
                                    <LinearDoubleKeyFrame KeyTime="0:0:0.4" Value="20" />
                                    <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0">
                                        <EasingDoubleKeyFrame.EasingFunction>
                                            <CubicEase EasingMode="EaseOut" />
                                        </EasingDoubleKeyFrame.EasingFunction>
                                    </EasingDoubleKeyFrame>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </Grid.Resources>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition To="Pressed" GeneratedDuration="0:0:0.1" />
                                    <VisualTransition From="Pressed" GeneratedDuration="0:0:0.1" />
                                </VisualStateGroup.Transitions>

                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver" />
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="content" Storyboard.TargetProperty="Opacity" To="0.35" Duration="0" />
                                        <DoubleAnimation Storyboard.TargetName="previousContent" Storyboard.TargetProperty="Opacity" To="0.35" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Rectangle Fill="{TemplateBinding Background}" />
                        <Rectangle Fill="#FFF7941E" Opacity="{ddhelpers:SelectBinding Binding={Binding Path=(ddhelpers:IsMouseOverHelper.IsMouseOver), RelativeSource={RelativeSource TemplatedParent}}, Converter={StaticResource TileMouseOverOpacityConverter}}" />

                        <ContentPresenter Name="content" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding CurrentContentTemplate}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          >
                            <ContentPresenter.RenderTransform>
                                <TranslateTransform />
                            </ContentPresenter.RenderTransform>
                        </ContentPresenter>
                        <ContentPresenter Name="previousContent" Content="{TemplateBinding PreviousContent}" ContentTemplate="{TemplateBinding CurrentContentTemplate}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          Visibility="Collapsed">
                            <ContentPresenter.RenderTransform>
                                <TranslateTransform />
                            </ContentPresenter.RenderTransform>
                        </ContentPresenter>
                        <ContentPresenter Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}"
                                          HorizontalAlignment="{TemplateBinding HorizontalHeaderAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalHeaderAlignment}"
                                          Margin="{TemplateBinding Padding}" />
                        <Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="dxdb:BaseControlTileSelector">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="dxdb:BaseControlTileSelector">
                    <Grid>
                        <helpers:TileLayoutControlExt x:Name="TileLayoutControl" Padding="0,30,0,0" GroupHeaderSpace="5" ItemContainerStyle="{StaticResource TileStyle}"
                            ItemTemplate="{TemplateBinding ItemTemplate}"
                            ItemTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                            GroupHeaderTemplate="{TemplateBinding GroupHeaderTemplate}"
                            ItemsSource="{TemplateBinding ItemsSource}"
                            AllowItemMoving="False" LayerSpace="40" ItemSpace="10"
                            HorizontalScrollBarStyle="{Binding Path=Resource, Source={StaticResource ScrollBarResource}}" VerticalScrollBarStyle="{Binding Path=Resource, Source={StaticResource ScrollBarResource}}" />
                        <Grid x:Name="grid" IsHitTestVisible="False">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="8"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="8"/>
                            </Grid.ColumnDefinitions>
                            <Border x:Name="LeftShadow" Margin="-8,0,0,0" Opacity="0.25" Visibility="{Binding ComputedLeftShadowVisibility, ElementName=TileLayoutControl}">
                                <Border.Background>
                                    <RadialGradientBrush>
                                        <GradientStop Color="Black" Offset="0"/>
                                        <GradientStop Color="#00000000" Offset="1"/>
                                    </RadialGradientBrush>
                                </Border.Background>
                            </Border>
                            <Border x:Name="RightShadow" Margin="0,0,-8,0" Opacity="0.25" Grid.Column="2" Visibility="{Binding ComputedRightShadowVisibility, ElementName=TileLayoutControl}">
                                <Border.Background>
                                    <RadialGradientBrush>
                                        <GradientStop Color="Black" Offset="0"/>
                                        <GradientStop Color="#00000000" Offset="1"/>
                                    </RadialGradientBrush>
                                </Border.Background>
                            </Border>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>  
</ResourceDictionary>
